﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quartz.Net.Factory;

namespace Quartz.Net.Core
{
    //[PersistJobDataAfterExecution]
    [DisallowConcurrentExecution]
    class TestJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {

            try
            {
                JobDataMap dataMap = context.JobDetail.JobDataMap;
                string content = dataMap.GetString("jobData");

                Process p = new Process();
                p.StartInfo.FileName = content;//程序地址
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//执行时隐藏
                p.Start();//启动程序
                p.WaitForExit();//等待进程关闭或退出后执行以下步骤
            }
            catch (Exception ex)
            {
                factoryClass.InsertRrrorlog(ex.Message, "任务执行失败",Quartz.Net.Model.LogsStatus.Fatal);
            }
            
        }
    }
}
